package com.usian.goods.controller;


import com.usian.goods.common.R;
import com.usian.goods.service.ITypeService;
import com.usian.model.goods.Type;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品分类表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-12-23
 */
@RestController
@RequestMapping("/type")
public class TypeController {
    @Autowired
    private ITypeService typeService;

    @RequestMapping("/findType")
    public R findType(Type type) {
        List<Type> list = typeService.findType(type);
        return R.success(list);
    }

    @RequestMapping("/addType")
    public R addType(@RequestBody Type type) {
        typeService.save(type);
        return R.success("添加成功");
    }

    @RequestMapping("/delType")
    public R delType(Integer id) {
        typeService.delete(id);
        return R.success("删除成功");
    }
}
